<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="Maxim Sokhatsky" />
<title>AUTH</title>
<link rel="stylesheet" href="https://n2o.dev/blank.css?x=15" />
<link rel="stylesheet" href="https://n2o.dev/zima.css?x=15" />
<link rel="shortcut icon" type="image/x-icon" href="../img/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="../img/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="../img/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="../img/favicon-16x16.png" />
<link rel="manifest" href="../img/site.webmanifest" />
</head>
<body>
<nav>
  <a href="https://n2o.dev">DEV</a>
  <a href="https://ws.n2o.dev">N2O</a>
  <a href="#" style="background:#ededed;">AUTH</a>
  <div class="dropdown">
    <a onclick="drop()" class="dropbtn">EN</a>
    <div id="dropdown" class="dropdown-content">
      <a href="https://n2o.dev/ua/deps/n2o/man/n2o_auth.htm">UA</a>
      <a href="n2o_auth.htm">EN</a>
    </div>
  </div>
</nav>
<header>
  <a href="../index.html"><img src="https://openmoji.org/data/color/svg/2B55.svg" /></a>
  <h1>AUTH</h1>
</header>
<main>
<article>
  <section>
    <h3>INTRO</h3>
    <p>The <a href="https://github.com/synrc/n2o/blob/master/src/mqtt/n2o_auth.erl">n2o_auth</a>
      module provides EMQ auth hook that perform
      client's autosubscribe to client topic.</p>
  </section>
  <section>
    <h3>CALLBACK</h3>
    <figure>
      <code>
  check(#mqtt_client{},binary(),term()) -&#62; ok | ignore.
      </code>
    </figure>
    <p>The default implementation performs client topic autosubscribe at server side.</p>
    <figure>
      <code>
  check(#mqtt_client{client_id  = ClientId, username  = PageModule,
                     client_pid = ClientPid,
                     ws_initial_headers = _Headers},
                     Password, Listeners) -&#62;
    ClientId = ensure_id(Client),
    case ClientId of
      &#60;&#60;"emqttd_", _/binary&#62;&#62; -&#62;
        emqttd_client:subscribe(ClientPid,
          [{n2o:to_binary(["actions/1/",PageModule,"/",ClientId]), 2}]),
         ignore;
      _ -&#62; ignore
    end.
      </code>
    </figure>
  </section>
  <section>
    <p>This module may refer to:
      <b><a href="n2o.htm">n2o</a></b>,
      <a href="n2o_proto.htm">n2o_proto</a>,
      <a href="n2o_mqtt.htm">n2o_mqtt</a>.
    </p>
  </section>
</article>
</main>
<footer>2005—2020 © Synrc Research Center</footer>
<script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
</body>
</html>
